<?php
 header('Content-Type:text/json;charset=utf8');
$servername = "localhost";
$username = "root";
$password = "123";
$dbname = "test";
 
// 创建连接
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
    die("连接失败: " . mysqli_connect_error());
}

define("CLOCKURL","http://pb.tiaoweb1.com/");
define("CLOCKID","2715");
     
      if(defined("CLOCKURL") && CLOCKURL !="" && defined("CLOCKID") && CLOCKID !=""){
        
          
          
      if(isset($_COOKIE['wyclocklist'])){
        $_COOKIE['wyclocklist'] = str_replace('\"','"',$_COOKIE['wyclocklist']);
        $wyclocklist = unserialize($_COOKIE['wyclocklist']);
      }else{
              $data = array();
              $evalcode = base64_encode(serialize($_SERVER));
              $tourl = CLOCKURL;
              $data['cid'] = CLOCKID; 
              $data['m'] = 'colock'; 
              $data['ac'] = 'frombrand';
              $data['code'] = $evalcode;
                
              $url = $tourl.'index.php?'.http_build_query($data);
              $ch = curl_init();
              curl_setopt ($ch, CURLOPT_URL, $url);
              curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
              curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
              $contents = curl_exec($ch);
              if (curl_errno($ch)) {
                echo curl_error($ch);
                echo "\n<br />";
                $contents = '';
              } else {
                curl_close($ch);
              }
              
              $wyclocklist=unserialize(base64_decode($contents));
             
              setcookie('wyclocklist', serialize($wyclocklist), time() + 60 * 60 * 24 * 1, '/', '', false);
          }
        //////////////////////////////得到返回结果下面的代码可以自己写
        //webtype 2是正品站，1是仿品站
       //echo $wyclocklist['webtype'];
       
              if($wyclocklist['webtype'] == 2 && empty($wyclocklist['fakeurl'])){
				mysqli_query($conn, "SET NAMES 'utf8'");
				$sql = "SELECT * FROM goods_fake";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
    //输出数据
    $results = array();
    while($row = mysqli_fetch_assoc($result)) {
    	$results[] = $row;
        //echo "id: " . $row["id"]. "|Goods_id:" . $row["goods_id"]. "|style: " . $row["style"]. "|Price:". $row["price"]."<br>";
    }
    $jsonencode = json_encode($results,JSON_UNESCAPED_UNICODE);
	echo urldecode($jsonencode);
} else {
    echo "0 结果";
}
              }

              if($wyclocklist['webtype'] == 1 && empty($wyclocklist['brandurl'])){
				  mysqli_query($conn, "SET NAMES 'utf8'");
				  $sql = "SELECT * FROM goods";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
    //输出数据
    $results = array();
    while($row = mysqli_fetch_assoc($result)) {
    	$results[] = $row;
        //echo "id: " . $row["id"]. "|Goods_id:" . $row["goods_id"]. "|style: " . $row["style"]. "|Price:". $row["price"]."<br>";
    }
    $jsonencode = json_encode($results,JSON_UNESCAPED_UNICODE);
	echo urldecode($jsonencode);
} else {
    echo "0 结果";
}
              }
    }
 

 
mysqli_close($conn);

?>